%
temporaryfolder=addbs(oprop.appstartpath)+[temp\]
*temporaryfolder=[temp\]
fromdate=orequest.form('datefrom')
todate=orequest.form('dateto')
if isnull(fromdate)
fromdate=NVL(orequest.querystring('datefrom'),'{}')
endif
if isnull(todate)
todate=NVL(orequest.querystring('dateto'),'{}')
endif
set date ymd
pdate1=ctod(fromdate)
pdate2=ctod(todate)
set date british
usesafe('acctran')
usesafe('glcodes')
usesafe('accounts')
openingbalancealias=sys(2015)
closingbalancealias=sys(2015)
SELECT [acctran]
SET ORDER TO acdate
retainedearnings=0
FILEstring=[
| DETAILS | DEBIT | CREDIT |
]
theglcode=[]
thisgl=[]
newgl=[xxx]
store space(0) to debitstr, creditstr, theglname
DO WHILE NOT EOF()
thisac=accountid
thisgl=left(thisac,2)
=seek(thisac,[accounts],[accountid])
thisacname=iif(empty(accounts.name),thisac+[ has no name],allt(accounts.name))
STORE 0 TO acbalance
do while not eof() and accountid=thisac
acbalance=acbalance+credit-debit
skip
enddo
if thisgl<>left(accountid,2)
newgl=left(accountid,2)
endif
if acbalance=0
loop
endif
if acbalance>0
glhead=[| ]+THISACname+[ | | ]+TRANSFORM(ABS(ACbalance),'999,999,999,999.99')+[ |
]
creditstr=creditstr+glhead
else
glhead=[| ]+THISACname+[ | ]+TRANSFORM(ABS(ACbalance),'999,999,999,999.99')+[ | |
]
debitstr=debitstr+glhead
endif
do Case
case val(thisgl)<12
netincome=netincome+acbalance
netincomecnt=netincomecnt+1
case val(thisgl)=12
netdirect=netdirect+acbalance
netdirectcnt=netdirectcnt+1
otherwise
netoffice=netoffice+acbalance
netofficecnt=netofficecnt+1
endcase
if val(thisgl)<12 and (val(newgl)>11 or eof())
do case
case netincome>0 and netincomecnt>1
glhead=creditstr+DEBITSTR+[| TOTAL INCOME | | ]+TRANSFORM(ABS(NETINCOME),'999,999,999,999.99')+[ |
]
case netincome>0 and netincomecnt=1
glhead=creditstr+DEBITSTR
case netincome<0 and netincomecnt>1
glhead=DEBITSTR+creditstr+[| TOTAL INCOME | ]+TRANSFORM(ABS(NETINCOME),'999,999,999,999.99')+[ | |
]
case netincome<0 and netincomecnt=1
glhead=DEBITSTR+creditstr
endcase
filestring=filestring+glhead+CHR(13)
STORE SPACE(0) TO DEBITSTR, creditstr
endif
if val(thisgl)=12 and (val(newgl)>12 or eof())
do case
case netdirect<0 and netdirectcnt>1
glhead=creditstr+DEBITSTR+[| LESS DIRECT EXPENSES | ]+TRANSFORM(ABS(netdirect),'999,999,999,999.99')+[ | |
]
case netdirect<0 and netdirectcnt=1
glhead=creditstr+DEBITSTR
case netdirect>0 and netdirectcnt>1
glhead=DEBITSTR+creditstr+[| LESS DIRECT EXPENSES | | ]+TRANSFORM(ABS(netdirect),'999,999,999,999.99')+[ |
]
case netdirect>0 and netdirectcnt=1
glhead=DEBITSTR+creditstr
endcase
filestring=filestring+glhead+CHR(13)
STORE SPACE(0) TO DEBITSTR, creditstr
IF NETINCOME+NETDIRECT=0
LOOP
ENDIF
IF NETINCOME+NETDIRECT>0
glhead=[| GROSS PROFIT | ]+TRANSFORM(ABS(NETINCOME+NETDIRECT),'999,999,999,999.99')+[ | |
]
filestring=filestring+glhead+CHR(13)
ELSE
glhead=[| GROSS LOSS | | ]+TRANSFORM(ABS(NETINCOME+NETDIRECT),'999,999,999,999.99')+[ |
]
filestring=filestring+glhead+CHR(13)
ENDIF
loop
endif
if eof()
do case
case netoffice<0 and netofficecnt>1
glhead=creditstr+DEBITSTR+[| LESS OFFICE EXPENSES | ]+TRANSFORM(ABS(netoffice),'999,999,999,999.99')+[ | |
]
case netoffice<0 and netofficecnt=1
glhead=creditstr+DEBITSTR
case netoffice>0 and netofficecnt>1
glhead=DEBITSTR+creditstr+[| LESS OFFICE EXPENSES | | ]+TRANSFORM(ABS(netoffice),'999,999,999,999.99')+[ |
]
case netoffice>0 and netofficecnt=1
glhead=DEBITSTR+creditstr
endcase
filestring=filestring+glhead+CHR(13)
STORE SPACE(0) TO DEBITSTR, creditstr
IF NETINCOME+NETDIRECT+netoffice=0
LOOP
ENDIF
IF NETINCOME+NETDIRECT+netoffice>0
glhead=[| NET PROFIT | ]+TRANSFORM(ABS(NETINCOME+NETDIRECT+netoffice),'999,999,999,999.99')+[ | |
]
filestring=filestring+glhead+CHR(13)
ELSE
glhead=[| NET LOSS | | ]+TRANSFORM(ABS(NETINCOME+NETDIRECT+netoffice),'999,999,999,999.99')+[ |
]
filestring=filestring+glhead+CHR(13)
ENDIF
endif
ENDDO
filestring=filestring+CHR(13)+[
]
%>